package com.qf.controller;

import com.qf.pojo.reqVo.OrderReq;
import com.qf.pojo.resVo.BaseResult;
import com.qf.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RequestMapping("/order")
@RestController
public class OrderController {


    @Autowired
    OrderService orderService;

    /**
     * 生成订单信息
     * @param orderReq
     * @param request
     * @return
     */
    @RequestMapping("/addOrder")
    public BaseResult addOrder(@RequestBody OrderReq orderReq, HttpServletRequest request){
        return orderService.addOrder(orderReq,request);
    }

    /**
     * 获取未支付得订单信息
     */
    @RequestMapping("/findOrderByUserId")
    public  BaseResult findOrderByUserId(HttpServletRequest request){
        return orderService.findOrderByUserId(request);
    }
    /**
     * 取消支付
     */
    @RequestMapping("/cancelPay")
    public BaseResult cancelPay(@RequestBody Map map){
        return orderService.cancelPay(map);
    }

    /**
     * 获取该用户的所有的订单信息
     */
    @RequestMapping("/findOldOrdersByUserid")
    public  BaseResult findOldOrdersByUserid(HttpServletRequest request){
        return orderService.findOldOrdersByUserid(request);
    }
}
